package com.tycoin.sync.job;

import java.text.SimpleDateFormat;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.Page;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import com.alibaba.fastjson.JSON;
import com.tycoin.account.slaveservice.TycoinAccountService;
import com.tycoin.trate.slaveentity.TycoinTradeOrder;
import com.tycoin.trate.slaveservice.TycoinTradeOrderService;
 

@Configuration
@EnableScheduling // 启用定时任务
public class SyncJob {
    private static final Log log = LogFactory.getLog(SyncJob.class);
    
    
    @Autowired
    private  TycoinAccountService tycoinAccountService;
    
    @Autowired
    private  TycoinTradeOrderService tycoinTradeOrderService;

    private static SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设置日期格式
    
    @Scheduled(cron = "0/180 * * * * ?") // 每180秒执行一次
    public void execute() {
         log.info("SyncJob Metadata begin.");
        long startTime = System.currentTimeMillis();
        try {
         	List<TycoinTradeOrder> btcList=tycoinTradeOrderService.getTycoinTradeOrderForCoinTypeList("BTC", 0);
        	List<TycoinTradeOrder> ltcList=tycoinTradeOrderService.getTycoinTradeOrderForCoinTypeList("LTC", 0);
        	List<TycoinTradeOrder> ethList=tycoinTradeOrderService.getTycoinTradeOrderForCoinTypeList("ETH", 0);
        	List<TycoinTradeOrder> etcList=tycoinTradeOrderService.getTycoinTradeOrderForCoinTypeList("ETC", 0);
            log.info("btcList"+JSON.toJSONString(btcList));
            log.info("ltcList"+JSON.toJSONString(ltcList));
            log.info("ethList"+JSON.toJSONString(ethList));
            log.info("etcList"+JSON.toJSONString(etcList));
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        log.info("SyncJob Metadata end run(" + (System.currentTimeMillis() - startTime) / 1000 + ")s.");
    }
 
}
